namespace NetSpell.SpellChecker.Dictionary.Phonetic
{
    using System;
    using System.Collections.ObjectModel;

    /// <summary>
    ///     A collection that stores 'PhoneticRule' objects.
    /// </summary>
    public class PhoneticRuleCollection : Collection<PhoneticRule>
    {
        #region Constructors

        /// <summary>
        ///     Initializes a new instance of 'PhoneticRuleCollection'.
        /// </summary>
        public PhoneticRuleCollection()
        {
        }

        /// <summary>
        ///     Initializes a new instance of 'PhoneticRuleCollection' based on an already existing instance.
        /// </summary>
        /// <param name='value'>
        ///     A 'PhoneticRuleCollection' from which the contents is copied
        /// </param>
        public PhoneticRuleCollection(PhoneticRuleCollection value)
        {
            this.AddRange(value);
        }

        /// <summary>
        ///     Initializes a new instance of 'PhoneticRuleCollection' with an array of 'PhoneticRule' objects.
        /// </summary>
        /// <param name='value'>
        ///     An array of 'PhoneticRule' objects with which to initialize the collection
        /// </param>
        public PhoneticRuleCollection(PhoneticRule[] value)
        {
            this.AddRange(value);
        }

        #endregion Constructors

        #region Methods

        /// <summary>
        ///     Copies the elements of an array at the end of this instance of 'PhoneticRuleCollection'.
        /// </summary>
        /// <param name='value'>
        ///     An array of 'PhoneticRule' objects to add to the collection.
        /// </param>
        public void AddRange(PhoneticRule[] value)
        {
            for (int Counter = 0; (Counter < value.Length); Counter = (Counter + 1))
            {
                this.Add(value[Counter]);
            }
        }

        /// <summary>
        ///     Adds the contents of another 'PhoneticRuleCollection' at the end of this instance.
        /// </summary>
        /// <param name='value'>
        ///     A 'PhoneticRuleCollection' containing the objects to add to the collection.
        /// </param>
        public void AddRange(PhoneticRuleCollection value)
        {
            for (int Counter = 0; (Counter < value.Count); Counter = (Counter + 1))
            {
                this.Add(value[Counter]);
            }
        }

        /// <summary>
        ///     Returns an enumerator that can be used to iterate through
        ///     the 'PhoneticRuleCollection'.
        /// </summary>
        public new PhoneticRuleEnumerator GetEnumerator()
        {
            return new PhoneticRuleEnumerator(this);
        }

        #endregion Methods
    }
}